<?
	require_once('init.php');
	require_once('dataModel.php');
	
	if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
	{
		$h_tourl="login.php";
		header("Location:".$h_tourl);
		exit;
	}

	$UserID=$_GET['ID'];
	$Type=$_GET['Type'];
	$pgno=$_GET['pgno'];
    
    if ($Type==0)
    {
    	$Title="新增会员";
		$strSQL = "select * from userInfo where 1=0";
		$imtype="0";
	}
    else if ($Type==1)
    {
    	$Title="修改会员资料";
		$strSQL = "select * from userInfo where id='".$UserID."' ";
    }

	$db = MySQL::getInstance('','r-w'); 
	$DBR=$db->query($strSQL); 
  	$result=$db->fetch($DBR);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<?='utf-8';?>" />
	<title><?=$AllPageTitle;?></title>
	<link href="css/CenterMenu.css" rel="stylesheet" type="text/css" />
	
	
	<? include("alljs.php"); ?>
	
	<script language="javascript">
		function goback(pgno)
		{
			self.location='usermanager.php?pgno='+pgno
		}

		function CheckData()
		{
			value = $("#userName").attr("value");
	       	if( value=="")
	       	{
				parent.hiAlert("请输入会员账号!", '系统提示');
				$("#userName").focus();
				return false;
	        }

			var strSQL = "";                      
			strSQL+= "&userName=";
			strSQL+=$("#userName").attr("value");
			strSQL+= "&userPWD=";
			strSQL+=$("#userPWD").attr("value");
			strSQL+= "&email=";
			strSQL+=$("#email").attr("value");
			strSQL+= "&telCode=";
			strSQL+=$("#telCode").attr("value");
			strSQL+= "&qqCode=";
			strSQL+=$("#qqCode").attr("value");
			strSQL+= "&realName=";
			strSQL+=$("#realName").attr("value");
			strSQL+= "&userAddress=";
			strSQL+=$("#userAddress").attr("value");
			strSQL+= "&Type=AddUserName";
			
//			alert (strSQL);
			
			$.post("varifyData.php",strSQL,function(msg)
			{

//			    alert (msg);
			    
			   	if (msg=='1')
			   	{	
					parent.hiAlert("数据保存成功!", '系统提示');
					
					$("#userName").attr("value","");
					$("#userPWD").attr("value","");
					$("#email").attr("value","");
					$("#telCode").attr("value","");
					$("#qqCode").attr("value","");
					$("#realName").attr("value","");
					$("#userAddress").attr("value","");
					
					$("#userName").focus();
					return false;
			   	}
			   	else if (msg=='2')
			   	{
					parent.hiAlert("该会员账号已经存在!", '系统提示');
					$("#userName").focus();
					return false;
			   	}
			})
	        
		}

   		function CheckDataEdit(EID)
   		{
			var strSQL = "";                      
			strSQL+= "&EID="+EID;
			strSQL+= "&userPWD=";
			strSQL+=$("#userPWD").attr("value");
			strSQL+= "&email=";
			strSQL+=$("#email").attr("value");
			strSQL+= "&telCode=";
			strSQL+=$("#telCode").attr("value");
			strSQL+= "&qqCode=";
			strSQL+=$("#qqCode").attr("value");
			strSQL+= "&realName=";
			strSQL+=$("#realName").attr("value");
			strSQL+= "&userAddress=";
			strSQL+=$("#userAddress").attr("value");
			strSQL+= "&Type=EditUserName";
			
//			alert (strSQL);
			
			$.post("varifyData.php",strSQL,function(msg)
			{

//			    alert (msg);
			    
			   	if (msg=='1')
			   	{	
					parent.hiAlert("数据保存成功!", '系统提示');
					
					$("#userPWD").focus();
					return false;
			   	}
			   	else if (msg=='2')
			   	{
					parent.hiAlert("该客服账号已经存在!", '系统提示');
					$("#userName").focus();
					return false;
			   	}
			})
	        
	    }    
	</script>
</head>


<body>
	<div id="MenuRighttitle" ><div style="padding-left:245px;padding-top:5px;"><b><?=$Title;?></b></div></div>

	<div class="inner-container">
		<div class="bodypart" style="border:0px solid blue;">	
			<div style="padding-left: 120px; margin-top: 20px; text-align: left; min-height: 300px;border:0px solid blue;">

				<div class="userpwd-a04" style="margin-top:20px;"><b><?="会员账号:";?></b></div>
				<?
				if ($Type==0)
				{
                ?>
					<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="userName" name="userName" value="<?=$result["userName"];?>" size="30" maxlength="50" class="userinfo_textbox" /></div>
                <?
                }
                else
                {
                ?>
					<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="userName" name="userName" disabled="disabled" value="<?=$result["userName"];?>" size="30" maxlength="50" class="userinfo_textbox" /></div>
                <?
                }
                ?>
				<div class="userpwd-a04" style="margin-top:20px;"><b><?="会员密码:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="password" id="userPWD" name="userPWD" value="" size="30" maxlength="30" class="userinfo_textbox" /></div>

				<div class="userpwd-a04" style="margin-top:20px;"><b><?="邮箱:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="email" name="email" value="<?=$result["email"];?>" size="30" maxlength="100" class="userinfo_textbox" /></div>

				<div class="userpwd-a04" style="margin-top:20px;"><b><?="联系电话:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="telCode" name="telCode" value="<?=$result["telCode"];?>" size="30" maxlength="20" class="userinfo_textbox" /></div>

				<div class="userpwd-a04" style="margin-top:20px;"><b><?="QQ号码:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="qqCode" name="qqCode" value="<?=$result["qqCode"];?>" size="30" maxlength="10" class="userinfo_textbox" /></div>
				
				<div class="userpwd-a04" style="margin-top:20px;"><b><?="真实姓名:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="realName" name=realName value="<?=$result["realName"];?>" size="30" maxlength="100" class="userinfo_textbox" /></div>
				
				<div class="userpwd-a04" style="margin-top:20px;"><b><?="用户地址:";?></b></div>
				<div class="userpwd-a05" style="margin-top:20px;"><input type="text" id="userAddress" name="userAddress" value="<?=$result["userAddress"];?>" size="30" maxlength="100" class="userinfo_textbox" /></div>

				<div class="userpwd-a01" style="margin-top: 20px;width:500px;text-align:center;border:0px solid blue;">
					<?
					if ($Type==0)
					{
					?>
						<input type="image" name="image" value="image" src="images/submit_btn.gif" onclick="javascript:CheckData();" /> 
					<?
					}
					else if ($Type==1)
					{
					?>
						<input type="image" name="image" value="image" src="images/submit_btn.gif" onclick="javascript:CheckDataEdit('<?=$result["id"];?>');" />
					<?
					}
					?>


					<input type="image" name="image" value="image" src="images/go_btn.gif" onclick="javascript:goback('<?=$pgno;?>');" /> 
				</div>
			</div>
		</div>
	</div>
</body>

</html>
